/*
 * =====================================================================================
 *
 *       Filename:  main.cc
 *
 *    Description:
 *
 *        Version:  1.0
 *        Created:  01/04/2022 11:09:21 AM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  first_name last_name (fl), fl@my-company.com
 *        Company:  my-company
 *
 * =====================================================================================
 */

#include "HanFeiziObservable.h"
#include "LiSiObserver.h"
#include "ZhouSiObserver.h"
#include <iostream>
using std::cout;
using std::endl;
using std::string;

void DoNew() {
    //IHanFeiZi.h, HanFeiZiNew.h, ILiSi.h, LiSi.h
    // cout << "----------用新的方法试试----------" << endl;
    //CHanFeiZiNew hanfeizi;
    //hanfeizi.HaveBreakfast();
    //hanfeizi.HaveFun();
}

void DoNewNew() {
    //IObservable.h, HanfeiziObservable.h, IObserver.h, LiSiObserver.h
    IObserver* pLiSi = new LiSiObserver();
    IObserver* pZhouSi = new ZhouSiObserver();
    HanFeiziObservable* pHanFeiZi = new HanFeiziObservable();
    pHanFeiZi->AddObserver(pLiSi);
    pHanFeiZi->AddObserver(pZhouSi);
    pHanFeiZi->HaveBreakfast();
    delete pLiSi;
    pLiSi = NULL;
    delete pHanFeiZi;
    pHanFeiZi = NULL;
}

int main() {
    //比较原始的方法，用线程来观察。
    //DoIt();
    //把李斯这个类聚集到韩非子这个类上，这样的话耦合度太高了，还是用更抽象的方式。
    DoNew();
    //更抽象的方式，想要观察韩非子的人多了去了，不可能只允许李斯观察。
    DoNewNew();
    return 0;
}
